package com.jboost.hyk.common.constant;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.jboost.common.constant.CommonConstant;
import com.jboost.common.constant.EnumInterface;

/**
 *@ClassName
 *@Description 在读年级
 *@Author cxn
 *@Date 2022-10-11
 *@Version
 **/
public enum SchoolGradeEnum implements EnumInterface {
//  在读年级：幼儿园、一年级、二年级、三年级、四年级、五年级、六年级、初一、初二、初三、高一、高二、高三、大一、大二、大三、社会人士
    GRADE_0(0,"幼儿园"),
    GRADE_1(1,"一年级"),
    GRADE_2(2,"二年级"),
    GRADE_3(3,"三年级"),
    GRADE_4(4,"四年级"),
    GRADE_5(5,"五年级"),
    GRADE_6(6,"六年级"),
    GRADE_7(7,"初一"),
    GRADE_8(8,"初二"),
    GRADE_9(9,"初三"),
    GRADE_10(10,"高一"),
    GRADE_11(11,"高二"),
    GRADE_12(12,"高三"),
    GRADE_13(13,"大一"),
    GRADE_14(14,"大二"),
    GRADE_15(15, "大三"),
    GRADE_16(16, "社会人士");

    SchoolGradeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    @EnumValue
    @JsonValue    //标记响应json值
    private final Integer code;
    private final String desc;

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }
    public static SchoolGradeEnum getByCode(Integer code) {
        SchoolGradeEnum[] enums = SchoolGradeEnum.values();
        for (int i = 0; i < enums.length; i++) {
            if(enums[i].code == code){
                return enums[i];
            }
        }
        return null;
    }
    public static SchoolGradeEnum getByDesc(String desc) {
        SchoolGradeEnum[] enums = SchoolGradeEnum.values();
        for (int i = 0; i < enums.length; i++) {
            if(enums[i].desc.equals(desc)){
                return enums[i];
            }
        }
        return null;
    }
    public static String getDescByCode(String code) {
        return code;
    }
    public static String getDescByCode(Integer code) {
        SchoolGradeEnum status = SchoolGradeEnum.getByCode(code);
        if(null == status){
            return CommonConstant.UNDIFIND_DEFALUT;
        }
        return status.getDesc();
    }
    public static Integer getCodeByDesc(String desc) {
        SchoolGradeEnum status = SchoolGradeEnum.getByDesc(desc);
        if(null == status){
            return CommonConstant.STATUS_DISABLE;
        }
        return status.getCode();
    }

    @Override
    public String desc() {
        return this.desc;
    }

    @Override
    public Integer value() {
        return this.code;
    }

    @Override
    public String code() {
        return String.valueOf(this.code);
    }

}
